package com.shangma.service;

import com.shangma.jian.JianMapper;
import com.shangma.nong.NongMapper;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

@Service("userService")
public class UserService {

    @Autowired
    private JianMapper jianMapper;
    @Autowired
    private NongMapper nongMapper;

    @GlobalTransactional(rollbackFor = Exception.class)
    public void transfer(int fromId, int toId, double money){
        nongMapper.reduceMoney(fromId,money);
        int a = 1/0;
        jianMapper.increaseMoney(toId,money);

    }
}
